﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CopySniffer.UI.Core.Controlers;
using CopySniffer.UI.Core;

namespace CopySniffer.UI.Views.WindowsForms
{
    public class CopySnifferApplicationContext : ApplicationContext
    {
        public CopySnifferApplicationContext()
        {
            ViewFactories.Default = new WindowsFormsViewFactory();
            mainControler = new MainControler();
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            mainControler.Closed += new EventHandler(mainControler_Closed);
            mainControler.Start();
        }

        MainControler mainControler;

        void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            mainControler.TreatUnhandledException(e.Exception);
        }

        void mainControler_Closed(object sender, EventArgs e)
        {
            Application.Exit();            
        }
    }
}
